<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:weixinset:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:weixinset:remove')}]];
        var prefix = ctx + "system/weixinset";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "支付设置",
                columns: [{
                    checkbox: false
                },
                {
                    field: 'id',
                    title: '编号',
                    visible: true
                },
                {
                    field: 'key',
                    title: '支付类型',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.key=='wx')
                            actions.push('<span class="badge badge-success">微信支付</span>');
                        if(row.key=='ali')
                            actions.push('<span class="badge badge-success">支付宝支付</span>');
                        return actions.join('');
                    }
                },
                {
                    field: 'state',
                    title: '状态',
                    visible: editFlag == 'hidden' ? false : true,
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>设置</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function statusTools(row) {
            if (row.state == 0) {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
            }
        }
        function disable(Id) {
            $.modal.confirm("确认要停用吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "id": Id, "state": 0 });
            })
        }

        /* 用户管理启用 */
        function enable(Id) {
            $.modal.confirm("确认要启用吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "id": Id, "state": 1 });
            })
        }
    </script>
</body>
</html>